import sys, pygame,os
pygame.init()
size = width,height =640, 640

speedX,speedY=0,0
incrementSize = 100
white = 255, 255, 255
screen = pygame.display.set_mode(size)
#apple = pygame.image.load("Apple.jpg")
#applerect = apple.get_rect()
ball = pygame.image.load("ball.jpg")
ballrect = ball.get_rect()
ballrect = ballrect.move(512,320)

while 1:
	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			sys.exit()
	#check if key pressed
	pygame.event.pump()
	key = pygame.key.get_pressed()
	if key[pygame.K_DOWN]:
		print 'down arrow pressed'
		speedY = incrementSize
	if key[pygame.K_UP]:
		speedY = -incrementSize
	if key[pygame.K_LEFT]:
		speedX = -incrementSize
	if key[pygame.K_RIGHT]:
		speedX = incrementSize
	#update accordingly	
	if ballrect.left < 0 or ballrect.right > width:
		speedY = 0
	if ballrect.top < 0 or ballrect.bottom > height:
		speedX = 0
	ballrect=ballrect.move(speedX,speedY)
	speedX=0
	speedY=0
	screen.fill(white)
	#screen.blit(apple,applerect)
	screen.blit(ball, ballrect)
	pygame.display.flip()
	pygame.time.delay(200/5)
	#check if key pressed
	#check if within bounds
	#update accordinly
	#print the new screen
	
